package List.collection;

import java.util.Objects;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/5
 */
public class Card implements Comparable<Card> {


    private String color;
    private String num;
    private int index;

    public Card() {
    }

    public Card(String color, String num, int index) {
        this.color = color;
        this.num = num;
        this.index = index;
    }

    /**
     * 获取
     * @return color
     */
    public String getColor() {
        return color;
    }

    /**
     * 设置
     * @param color
     */
    public void setColor(String color) {
        this.color = color;
    }

    /**
     * 获取
     * @return num
     */
    public String getNum() {
        return num;
    }

    /**
     * 设置
     * @param num
     */
    public void setNum(String num) {
        this.num = num;
    }

    /**
     * 获取
     * @return index
     */
    public int getIndex() {
        return index;
    }

    /**
     * 设置
     * @param index
     */
    public void setIndex(int index) {
        this.index = index;
    }
    public String toString() {
        return color+num;  //♥A  ♦Q
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return index == card.index && Objects.equals(color, card.color) && Objects.equals(num, card.num);
    }
    @Override
    public int hashCode() {
        return Objects.hash(color, num, index);
    }
    @Override
    public int compareTo(Card o) {
        return this.index - o.index;
    }
}
